from ticketquest.ticketer import Ticket, Comment
from django.conf import settings
import logging


class EmailParser():
    """
    Parses emails sent in from end users and creates ticket objects from them.
    """
    ticket = {}
    comment = {}
    mailserver = settings.MAILSERVER
    mailuser = settings.MAILUSER
    mailpassword = settings.MAILPASSWORD

    #LOGGING
    logging.basicConfig(filename='./logs/ticketer.log', format='[%(asctime)s]: %(message)s', level=logging.INFO, datefmt="%m/%d/%Y %I:%M:%S %p")
    logger = logging.getLogger('exception_parser')
    logger.propagate = True
    formatter = logging.Formatter('|parser| [%(asctime)s]: %(message)s', datefmt="%m/%d/%Y %I:%M:%S %p")
    rotating_handler = handlers.RotatingFileHandler(filename=logfile, mode='a', maxBytes=1000000, backupCount=3)
    rotating_handler.setFormatter(formatter)
    
